<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('辅助明细账')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>年度：</label>
                                <input type="text" id="nd" name="params[nd]" th:value="${year}"/>
                            </li>
                            <li>
                                <label>起月份：</label>
                                <input type="text" id="syf" name="params[syf]" th:value="${term}"/>
                            </li>
                            <li>
                                <label>止月份：</label>
                                <input type="text" id="eyf" name="params[eyf]" th:value="${term}"/>
                            </li>
                            <li style="width:265px">
                                <label>科目代码：</label>
                                 <div class="input-group">
	                                <input class="form-control" type="text" ondblclick="selectKmdmTree()" id="kmdm"  name="params[kmdm]">
	                        		<span class="input-group-addon"><i class="fa fa-search" onclick="selectKmdmTree()"></i></span>
                        		 </div>
                            </li>
							<li style="width:265px">
                                <label>单位编码：</label>
			                    <div class="input-group"> 
			                        <input class="form-control" type="text" ondblclick="selectHsdwTree()" id="dwbm" name="params[dwbm]">
			                        <span class="input-group-addon"><i class="fa fa-search" onclick="selectHsdwTree()"></i></span>
			                    </div>
                            </li>
                            <li style="width:265px">
                                <label>预算科目：</label>
                                 <div class="input-group">
	                                <input class="form-control" type="text" ondblclick="selectYskmTree()" id="yskm"  name="yskm">
	                        		<span class="input-group-addon"><i class="fa fa-search" onclick="selectYskmTree()"></i></span>
                        		 </div>
                            </li>
                            <li>
                                <label>未记账：</label>
                                <input type="checkbox" name="params[sfjz]" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:fzmxaccount:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table">
                  <table>
		  			<tr><td>核算期间:</td></tr>
		  			<tr><td>凭证范围:</td></tr>
		  		  </table>
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript"> 
        var prefix = ctx + "system/fzmxaccount";
        $(function() {
            var options = {
                url: prefix + "/list", 
                exportUrl: prefix + "/export",
                modalName: "辅助明细账",
                showFooter: true,
                firstLoad: false,
                columns: [{
                    checkbox: true
                },
                {
		            field: 'pztxh',
		            visible: false
		        },
                {
                    field: 'nd',
                    title: '年'
                },{
                    field: 'yf',
                    title: '月'
                },{
                    field: 'rq',
                    title: '日'
                },{
                    field: 'pzzh',
                    title: '凭证字号'
                },{
                    field: 'zy',
                    title: '摘要'
                },
                {
                    field: 'pjh',
                    title: '票据号'
                },{
                    field: 'dwbm',
                    title: '单位编码'
                },{
                    field: 'dwbm',
                    title: '单位名称'
                },{
                    field: 'yskm',
                    title: '预算科目'
                },{
                    field: 'yskmmc',
                    title: '预算科目名称'
                },
                {
                    field: 'jfje',
                    title: '借方金额'
                },
                {
                    field: 'dfje',
                    title: '贷方金额'
                },{
                    field: 'jdfx',
                    title: '借贷方向',
		        	formatter: function (value, row, index) {
		        		return status(row);
		        	}
                },{
                    field: 'qmye',
                    title: '余额'
                },{
                    field: 'sfjz',
                    title: '是否记账',
		        	formatter: function (value, row, index) {
		        		return statusTools(row);
		        	}
                }]
            };
            $.table.init(options);
        });
        
		function query() {
        	var nd=$("#nd").val();
        	var syf=$("#syf").val();
        	var eyf=$("#eyf").val();
        	var kmdm=$("#kmdm").val();
        	debugger;
        	if (nd==''){
        		$.modal.alertWarning("查询年度不能为空");
        		return false;
        	}
        	if (syf==''||eyf==''){
        		$.modal.alertWarning("查询起止月份不能为空");
        		return false;
        	}
        	if (kmdm==''){
        		$.modal.alertWarning("科目代码不能为空");
        		return false;
        	}
        	$.table.search();
        }
    	/* 用户状态显示 */
		function status(row) {
		    if (row.jdfx =='1') {
    			return '借';
    		} else if (row.jdfx =='-1'){
    			return '贷';
    		}else{
    			return '';
    		}
		}
		function statusTools(row) {
		    if (row.sfjz == 1) {
    			return '<i class=\"fa fa-check text-info fa-2x\" ></i> ';
    		}
		}
	     /*会计科目-新增-选择父部门树*/
        function selectKmdmTree() {
            var options = {
                title: '会计科目选择',
                width: "380",
                url: ctx + "system/kmdm/selectKmdmTree/",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
               var body = layer.getChildFrame('body', index);
               $("#kmdm").val(body.find('#treeId').val());
               layer.close(index);
        }
    	
		   /*核算单位-新增-选择父部门树*/
        function selectHsdwTree() {
            var options = {
                title: '核算单位选择',
                width: "380",
                url: ctx + "system/hsdw/selectHsdwTree/",
                callBack: dohsdwSubmit
            };
            $.modal.openOptions(options);
        }

        function dohsdwSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#dwbm").val(body.find('#treeId').val());
               layer.close(index);
        }
        
    	
		   /*核算单位-新增-选择父部门树*/
     function selectYskmTree() {
         var options = {
             title: '预算科目选择',
             width: "380",
             url: ctx + "system/yskm/selectYskmTree/",
             callBack: doyskmSubmit
         };
         $.modal.openOptions(options);
     }

     function doyskmSubmit(index, layero){
         var body = layer.getChildFrame('body', index);
            $("#yskm").val(body.find('#treeId').val());
            layer.close(index);
     }
    </script>
</body>
</html>